package ctx

import (
	"github.com/sirupsen/logrus"
	"strings"
)

type Context struct {
	logger *logrus.Entry
}

func (c *Context) Log() *logrus.Entry {
	return c.logger
}

func (c *Context) SetLog(l *logrus.Entry) {
	c.logger = l
}

func (c *Context) ErrLog(err error) *logrus.Entry {
	return c.logger.WithError(err)
}

// 去除字符串前后空白字符，用法:
// c.Trim(&str1, &str2, ...)
func (c *Context) Trim(args ...*string) {
	for _, v := range args {
		*v = strings.TrimSpace(*v)
	}
}
